{include file="Public:header2"/}
<body>
<div class="layui-fluid">
    <div class="layui-card">
        <form method="get" class="layui-form layui-card-header layuiadmin-card-header-auto">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <div class="layui-input-inline" style="width: 300px;margin-left: 0px">
                        <input type="text" name="title" value="{$Request.get.title}" placeholder="请输入盒子标题" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <div class="layui-input-inline" style="width: 300px;margin-left: 0px">
                        <select name="status" style="width:100%">
                            <option value="">--请选择状态--</option>
                            <option value="1" {if condition="$Request.get.status eq 1"}selected{/if}>正常</option>
                            <option value="2" {if condition="$Request.get.status eq 2"}selected{/if}>下架</option>
                            <option value="3" {if condition="$Request.get.status eq 3"}selected{/if}>售罄</option>
                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <button class="layui-btn layuiadmin-btn-useradmin mmm" lay-submit lay-filter="LAY-user-front-search">
                        <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                    </button>
                </div>
            </div>
        </form>

        <div class="layui-card-body">
            <xblock>
                <div style="padding-bottom: 10px;">
                    <a class="layui-btn" onclick="card_goods_add()">添加盒子</a>
                    <span style="line-height:40px;float:right;">共有数据： {$count}条</span>
                </div>
            </xblock>
            <table class="layui-table">
                <thead>
                <tr>
                    <th>盒子ID</th>
                    <th>盒子分类</th>
                    <th>盒子名称</th>
                    <th>盒子价格</th>
                    <th>显示价格</th>
                    <th>盒子图片</th>
                    <th>张数</th>
<!--                    <th>盒子详情图片</th>-->
<!--                    <th>卡牌背面</th>-->
<!--                    <th>卡册banner</th>-->
                    <th>发券开关</th>
                    <!--<th>发积分开关</th>-->
                    <th>排序</th>
                    <th>状态</th>

                    <th>销量</th>
                    <th>添加时间</th>
<!--                    <th>信息</th>-->
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                {volist name="list" id="vo"}
                <tr>
                    <td>{$vo['id']}</td>
                    <td><button class="layui-btn layui-btn-info layui-btn-radius layui-btn-sm">{$vo.category_name}</button></td>
                    <td>{$vo['title']}</td>
                    <td>{$vo['price']}</td>
                    <td>{$vo['show_price']}</td>
                    <td><img src="{PHP} echo imageUrl($vo['imgurl']){/php}" style="width:60px;height:60px;"></td>
                    <td>{$vo['card_num']}</td>
<!--                    <td>{if $vo['imgurl_detail']}<img src="{PHP} echo imageUrl($vo['imgurl_detail']){/php}" style="width:60px;height:60px;">{/if}</td>-->
<!--                    <td>{if $vo['prize_imgurl']}<img src="{PHP} echo imageUrl($vo['prize_imgurl']){/php}" style="width:60px;height:60px;">{/if}</td>-->
<!--                    <td>{if $vo['card_banner']}<img src="{PHP} echo imageUrl($vo['card_banner']){/php}" style="width:60px;height:60px;">{/if}</td>-->
                    <td>
                        {if $vo['coupon_is'] eq 1}
                        <button class="layui-btn layui-btn-warm layui-btn-sm">状态：开启</button>
                        <br>
                        <button class="layui-btn layui-btn-warm layui-btn-sm">概率：{$vo['coupon_pro']*1}%</button>
                        {/if}
                    </td>
                    <!--<td>-->
                    <!--    {if $vo['integral_is'] eq 1}-->
                    <!--    <button class="layui-btn layui-btn-warm layui-btn-radius layui-btn-sm">开启</button>-->
                    <!--    {/if}-->
                    <!--</td>-->
                    <td>{$vo['sort']}</td>
                    <td>
                        {if $vo['status'] eq 1}
<!--                        <button class="layui-btn layui-btn-sucess layui-btn-radius layui-btn-sm">上架</button>-->
                        <button onClick="card_del({$vo.id},2,'下架')" class="layui-btn layui-btn-danger layui-btn-xs"><i class="layui-icon">&#xe61a;</i>下架</button>
                        {elseif  $vo['status'] eq 2}
<!--                        <button class="layui-btn layui-btn-danger layui-btn-radius layui-btn-sm">下架</button>-->
                        <button onClick="card_del({$vo.id},1,'上架')" class="layui-btn layui-btn-info layui-btn-xs"><i class="layui-icon">&#xe619;</i>上架</button>
                        {elseif  $vo['status'] eq 3}
                        <button class="layui-btn layui-btn-disabled layui-btn-radius layui-btn-sm">售罄</button>
                        {/if}
                    </td>

                    <td>
                        <p>销量:{$vo['all_sale_stock']}</p>
                        <p>库存:{$vo.all_special_stock}</p>
                    </td>
                    <td>{$vo['addtime']|date="Y-m-d H:i"}</td>
                    <!--                        <td>-->
                    <!--                            {volist name="vo.shang" id="voo"}-->
                    <!--                            <p style="display: block">-->
                    <!--                                <span>{$voo.title}</span>-->
                    <!--                                <span style="margin-left: 3px;">{$voo.pro*1}%</span>-->
                    <!--                                <span style="color: #3b97d7;margin-left: 10px">{$voo.goodslist_count}种奖品</span>-->
                    <!--                                <span style="margin-left: 10px">{$voo.sale_stock}销量</span>-->
                    <!--                                <span style="margin-left: 10px">{$voo.special_stock}库存</span>-->
                    <!--                            </p>-->
                    <!--                            <br>-->
                    <!--                            {/volist}-->
                    <!--                        </td>-->
                    <td>
<!--                        <a style="text-decoration:none" onclick="card_goods_edit_number({$vo.id},'{$vo.title}')"  class="layui-btn layui-btn-normal layui-btn-xs">-->
<!--                            <i class="layui-icon layui-icon-edit"></i>编辑抽数-->
<!--                        </a>-->
<!--                        <div style="margin-top: 8px"></div>-->
                        <a style="text-decoration:none" onclick="card_goods_edit({$vo.id})"  class="layui-btn layui-btn-normal layui-btn-xs">
                            <i class="layui-icon layui-icon-edit"></i>编辑盒子
                        </a>
                        <br>
                        <div style="margin-top: 8px"></div>
                        <!--                            <a style="text-decoration:none" onclick="card_shang({$vo['id']},'{$vo.title}')"  class="layui-btn layui-btn-warm layui-btn-xs">卡等级</a>-->
                        <a style="text-decoration:none" onclick="card_goodslist({$vo['id']},'{$vo.title}')"  class="layui-btn layui-btn-warm layui-btn-xs"><i class = ' layui-icon layui-icon-add-1'></i>添加奖品</a>
                        <div style="margin-top: 8px"></div>
                        <a style="text-decoration:none" onClick="card_del({$vo.id},3,'删除')" class="layui-btn layui-btn-danger layui-btn-xs">
                            <i class="layui-icon layui-icon-delete"></i>删除
                        </a>
                    </td>
                </tr>
                {/volist}

                {if condition="empty($list)"}
                <tr><td colspan='11' style="text-align:center;">暂时没有数据！</td></tr>
                {/if}

                </tbody>
            </table>
            <div class="layui-box layui-laypage layui-laypage-default">
                {$page|raw}
            </div>
        </div>
    </div>
</div>
{include file="Public:footer"/}
<script type="text/javascript">
    layui.use(['layer','table'], function(){
        var $ = layui.$;


    })

    //添加盒子
    function card_goods_add() {
        var url  = "{:url('/admin/card_goods_add')}";
        layer.open({
            type: 2,
            title: '添加盒子',
            shadeClose: false,
            shade: 0.3,
            area: ['90%', '90%'],
            content: url,
        });
    }

    //编辑盒子
    function card_goods_edit(id) {
        var url  = "{:url('/admin/card_goods_edit?id="+id+"')}";
        layer.open({
            type: 2,
            title: '编辑盒子',
            shadeClose: false,
            shade: 0.3,
            area: ['90%', '90%'],
            content: url,
        });
    }

    //编辑抽数
    function card_goods_edit_number(id,title) {
        var url  = "{:url('/admin/card_goods_edit_number?id="+id+"')}";
        layer.open({
            type: 2,
            title: title + ' 编辑抽数',
            shadeClose: false,
            shade: 0.3,
            area: ['70%', '90%'],
            content: url,
        });
    }


    //上下架 删除
    function card_del(id,type,type_name){
        layer.confirm('确认要执行'+type_name+'操作吗？',function(){
            var url = "{:url('/admin/card_goods_del')}";
            var load=layer.load(2);
            var $ = layui.$;
            $.post(url,{"id":id,'type':type},function(data){
                if(data.status == 1){
                    layer.msg('操作成功',{icon:1,time:1000},function(){
                        location.reload();
                    });
                }else{
                    layer.msg(data.msg,{icon:2,anim:6,time:1000},function(){
                        layer.close(load);
                    });
                }
            })
        });
    }

    //卡等级
    function card_shang(goods_id,title) {
        var url  = "{:url('/admin/card_shang?goods_id="+goods_id+"')}";
        layer.open({
            type: 2,
            title: title+'  卡等级',
            shadeClose: false,
            shade: 0.3,
            area: ['90%', '90%'],
            content: url,
        });
    }

    //盒子奖品
    function card_goodslist(card_id,title) {
        var url  = "{:url('/admin/shang_goods?card_id="+card_id+"')}";
        layer.open({
            type: 2,
            title: title+'  等级奖品',
            shadeClose: false,
            shade: 0.3,
            area: ['95%', '95%'],
            content: url,
        });
    }


</script>
</body>
</html>


